package com.lx.patterns.iterator;

import java.util.List;

/**
 * @ClassName StudentIteratorImpl
 * @Description: 具体迭代器对象
 * @Author: 落雪
 * @CreateDate: 2025/2/15 10:51
 * @UpdateUser: 落雪
 * @UpdateDate: 2025/2/15 10:51
 * @UpdateRemark:
 * @Version: 1.0
 */
public class StudentIteratorImpl implements StudentIterator{

    private List<Student> studentList;

    private int index = 0;

    public StudentIteratorImpl(List<Student> studentList) {
        this.studentList = studentList;
    }
    @Override
    public boolean hasNext() {
        return index<studentList.size();
    }

    @Override
    public Student next() {
        Student student = studentList.get(index);
        index++;
        return student;
    }
}
